package com.model;

import com.common.json.FAQJson;
import com.employee.controller.FAQBeanRemote;
import com.entities.FAQ;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.jsp.tagext.TryCatchFinally;

public class FAQModel
{
    
    public List<FAQ> fillFAQ(){
        try
        {
            List<FAQ> lst = new ArrayList<>();
            InitialContext ic = new InitialContext();
            FAQBeanRemote remote = (FAQBeanRemote) ic.lookup("java:global/BluePumpkinEJB/FAQBean!com.employee.controller.FAQBeanRemote");
            List<String> lstJson = remote.getAllFAQ();
            for (String json : lstJson)
            {
                FAQ faq = FAQJson.convertJSONObjectStringToFAQ(json);
                lst.add(faq);
            }
            return lst;
        } catch (NamingException ex)
        {
            Logger.getLogger(FAQModel.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
}
